package com.bluedot.ssh.phone;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.Serializable;

public class Photo implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long id;
	private File minFile;
	private File maxFile;
	private byte[] minPhotoData;
	private byte[] maxPhotoData;
	private Phone phone;

	/**
	 * @return the id
	 */
	public long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * @return the minFile
	 */
	public File getMinFile() {
		return minFile;
	}

	/**
	 * @param minFile
	 *            the minFile to set
	 */
	public void setMinFile(File minFile) {
		this.minFile = minFile;
	}

	/**
	 * @return the maxFile
	 */
	public File getMaxFile() {
		return maxFile;
	}

	/**
	 * @param maxFile
	 *            the maxFile to set
	 */
	public void setMaxFile(File maxFile) {
		this.maxFile = maxFile;
	}

	/**
	 * @return the minPhotoData
	 */
	public byte[] getMinPhotoData() {
		if (this.minPhotoData == null && this.minFile != null) {
			try {
				InputStream inputStream = new FileInputStream(this.minFile);
				this.minPhotoData = new byte[inputStream.available()];
				inputStream.read(this.minPhotoData);
				inputStream.close();
			} catch (Exception e) {
				// TODO 处理异常，创建product的运行异常类族
				e.printStackTrace();
			}
		}
		return minPhotoData;
	}

	/**
	 * @param minPhotoData
	 *            the minPhotoData to set
	 */
	public void setMinPhotoData(byte[] minPhotoData) {
		this.minPhotoData = minPhotoData;
	}

	/**
	 * @return the maxPhotoData
	 */
	public byte[] getMaxPhotoData() {
		if (this.maxPhotoData == null && this.maxFile != null) {
			try {
				InputStream inputStream = new FileInputStream(this.maxFile);
				this.maxPhotoData = new byte[inputStream.available()];
				inputStream.read(this.maxPhotoData);
				inputStream.close();
			} catch (Exception e) {
				// TODO 处理异常，创建product的运行异常类族
				e.printStackTrace();
			}
		}
		return maxPhotoData;
	}

	/**
	 * @param maxPhotoData
	 *            the maxPhotoData to set
	 */
	public void setMaxPhotoData(byte[] maxPhotoData) {
		this.maxPhotoData = maxPhotoData;
	}

	/**
	 * @return the phone
	 */
	public Phone getPhone() {
		return phone;
	}

	/**
	 * @param phone
	 *            the phone to set
	 */
	public void setPhone(Phone phone) {
		this.phone = phone;
	}
}
